package com.itsu.app.controller;

import com.itsu.api.controllerApi.UserControllerApi;
import com.itsu.app.service.AppUserInfoService;
import com.itsu.app.service.AppUserService;
import com.itsu.pojo.dto.UserInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class UserController implements UserControllerApi {

    @Autowired
    AppUserService appUserService;

    @Autowired
    AppUserInfoService appUserInfoService;

    @Override
    public ResponseEntity login(Map<String, String> params) {
        appUserService.sendMag(params.get("phone"));
        return ResponseEntity.ok(null);
    }

    @Override
    public ResponseEntity loginVerification(Map<String, String> params) {
        Map<String, Object> data = appUserService.loginVerification(params.get("phone"), params.get("verificationCode"));
        return ResponseEntity.ok(data);
    }

    @Override
    public ResponseEntity loginReginfo(UserInfoDTO userInfoDTO) {
        appUserInfoService.loginReginfo(userInfoDTO);
        return ResponseEntity.ok(null);
    }

    @Override
    public ResponseEntity loginReginfoHead(MultipartFile headPhoto) {
        appUserInfoService.loginReginfoHead(headPhoto);
        return ResponseEntity.ok(null);
    }
}
